home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / RelationView.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  35.6 KB  |  1,219 lines

  1. package symantec.itools.db.pro;
  2.  
  3. import java.io.EOFException;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.util.Hashtable;
  7. import java.util.Properties;
  8. import java.util.Vector;
  9. import symantec.itools.db.net.Entity;
  10. import symantec.itools.db.net.NetData;
  11. import symantec.itools.db.net.NetRecord;
  12. import symantec.itools.db.net.NetString;
  13. import symantec.itools.db.net.RemoteObject;
  14. import symantec.itools.db.net.SQLConnectionException;
  15. import symantec.itools.db.net.TextParam;
  16. import symjava.lang.Bignum;
  17. import symjava.sql.Date;
  18. import symjava.sql.SQLException;
  19. import symjava.sql.Time;
  20. import symjava.sql.Timestamp;
  21.  
  22. public class RelationView implements DataAccess {
  23.    private RemoteObject _messgr;
  24.    private Session _session;
  25.    private MultiView _mv;
  26.    private RelationView _parRV;
  27.    private RelationViewMetaData _metadata;
  28.    private int _proxyID;
  29.    private RecordSet _block;
  30.    private Record _rec;
  31.    private Hashtable _colNames;
  32.    private int _curRecNum;
  33.    private int _numRowsToRequest;
  34.    private Vector _binds;
  35.    private Vector _recordBinds;
  36.    private Vector _detailRVs;
  37.    private byte _rvID;
  38.    private String _name;
  39.    private ConnectionInfo _conn;
  40.    private boolean _notifyEnabled;
  41.    private boolean _enableDetailSQL;
  42.    private final int METHOD_getPreparedRelView;
  43.    private final int METHOD_setName;
  44.    private final int METHOD_filter;
  45.    private final int METHOD_clearFilter;
  46.    private final int METHOD_getListProxy;
  47.    public static final int DEFAULTSCALE = 0;
  48.    public static final int SETBLANKTODEFAULT = 0;
  49.    public static final int SETBLANKTONULL = 1;
  50.    public static final int SETBLANKTOEMPTY = 2;
  51.  
  52.    public RelationView(Request request) throws SQLException {
  53.       this(request.getSession(), request.getConnectionInfo(), request.getSQL(), request);
  54.    }
  55.  
  56.    public RelationView(AutoDetail detail) throws SQLException {
  57.       this._notifyEnabled = true;
  58.       this._enableDetailSQL = true;
  59.       this.METHOD_getPreparedRelView = 1;
  60.       this.METHOD_setName = 3;
  61.       this.METHOD_filter = 4;
  62.       this.METHOD_clearFilter = 5;
  63.       this.METHOD_getListProxy = 6;
  64.       Vector results = detail.getExecuteRequestResults();
  65.       RelationView rv = detail.getRelationView();
  66.       MultiView mv = rv.getMultiView();
  67.       this.init(rv.getSession(), mv, rv, results, mv.getNextLevelID(), ((Request)detail).getConnectionInfo());
  68.       rv.addDetailRelView(this);
  69.       if (((Request)detail).getInitialRecordPos().equals(Request.REC_POS_FIRST)) {
  70.          this.first();
  71.       } else {
  72.          if (((Request)detail).getInitialRecordPos().equals(Request.REC_POS_NEW)) {
  73.             this.getNewRecord();
  74.          }
  75.  
  76.       }
  77.    }
  78.  
  79.    RelationView(Session session, ConnectionInfo conn, String sql, Properties requestProps) throws SQLException {
  80.       this._notifyEnabled = true;
  81.       this._enableDetailSQL = true;
  82.       this.METHOD_getPreparedRelView = 1;
  83.       this.METHOD_setName = 3;
  84.       this.METHOD_filter = 4;
  85.       this.METHOD_clearFilter = 5;
  86.       this.METHOD_getListProxy = 6;
  87.       Hashtable ht = convertViewProps(requestProps);
  88.       MultiView mv = session.createMultiView(conn, sql, ht);
  89.       Properties ctorProperties = mv.getRootRVCtorProperties();
  90.       Vector ctorParams = (Vector)((Hashtable)ctorProperties).get("ctorParams");
  91.       byte rvID = mv.getNextLevelID();
  92.       this.init(session, mv, (RelationView)null, ctorParams, rvID, conn);
  93.       mv.setRootRelView(this);
  94.       this.setInitialPosition(requestProps);
  95.    }
  96.  
  97.    RelationView(MultiView mv, byte rvID, ConnectionInfo conn) throws SQLException {
  98.       this._notifyEnabled = true;
  99.       this._enableDetailSQL = true;
  100.       this.METHOD_getPreparedRelView = 1;
  101.       this.METHOD_setName = 3;
  102.       this.METHOD_filter = 4;
  103.       this.METHOD_clearFilter = 5;
  104.       this.METHOD_getListProxy = 6;
  105.       Properties ctorProperties = mv.getRootRVCtorProperties();
  106.       Session session = (Session)((Hashtable)ctorProperties).get("session");
  107.       Vector ctorParams = (Vector)((Hashtable)ctorProperties).get("ctorParams");
  108.       this.init(session, mv, (RelationView)null, ctorParams, rvID, conn);
  109.    }
  110.  
  111.    void setInitialPosition(Properties requestProps) throws SQLException {
  112.       Hashtable ht = convertViewProps(requestProps);
  113.       String recPos = (String)ht.get("recPosition");
  114.       if (recPos.equals(Request.REC_POS_FIRST)) {
  115.          this.first();
  116.       } else {
  117.          if (recPos.equals(Request.REC_POS_NEW)) {
  118.             this.getNewRecord();
  119.          }
  120.  
  121.       }
  122.    }
  123.  
  124.    static Hashtable convertViewProps(Properties viewProps) {
  125.       Hashtable ht = new Hashtable();
  126.       ht.put("user", viewProps.getProperty("user", ""));
  127.       ht.put("password", viewProps.getProperty("password", ""));
  128.       String value = viewProps.getProperty("optConc", Request.UNIQUE_MODIFIED);
  129.       ht.put("optConc", Integer.valueOf(value));
  130.       value = viewProps.getProperty("recPosition", Request.REC_POS_NOPOS);
  131.       ht.put("recPosition", new String(value));
  132.       value = viewProps.getProperty("maxRecords", "200");
  133.       ht.put("maxRecords", Integer.valueOf(value));
  134.       value = viewProps.getProperty("readOnly", "true");
  135.       ht.put("readOnly", Boolean.valueOf(value));
  136.       value = viewProps.getProperty("sharable", "true");
  137.       ht.put("sharable", Boolean.valueOf(value));
  138.       return ht;
  139.    }
  140.  
  141.    RelationView(Session session, MultiView mv, RelationView parRV, Vector ctorParams, byte rvID, ConnectionInfo conn) throws SQLException {
  142.       this._notifyEnabled = true;
  143.       this._enableDetailSQL = true;
  144.       this.METHOD_getPreparedRelView = 1;
  145.       this.METHOD_setName = 3;
  146.       this.METHOD_filter = 4;
  147.       this.METHOD_clearFilter = 5;
  148.       this.METHOD_getListProxy = 6;
  149.       this.init(session, mv, parRV, ctorParams, rvID, conn);
  150.    }
  151.  
  152.    Session getSession() {
  153.       return this._session;
  154.    }
  155.  
  156.    ConnectionInfo getConn() {
  157.       return this._conn;
  158.    }
  159.  
  160.    void init(Session session, MultiView mv, RelationView parRV, Vector ctorParams, byte rvID, ConnectionInfo conn) throws SQLException {
  161.       this._parRV = parRV;
  162.       this._rvID = rvID;
  163.       this._curRecNum = 0;
  164.       this._conn = conn;
  165.       this._block = null;
  166.       this._rec = null;
  167.       this._mv = mv;
  168.       this._session = session;
  169.       this._detailRVs = new Vector();
  170.       NetData d = (NetData)ctorParams.elementAt(0);
  171.  
  172.       int id;
  173.       try {
  174.          id = d.getInt();
  175.       } catch (EOFException e) {
  176.          throw new SQLException(((Throwable)e).getMessage());
  177.       }
  178.  
  179.       this._proxyID = id;
  180.       this._messgr = new RemoteObject("CSCLRelView", id, session.getClientSession());
  181.       NetString s = (NetString)ctorParams.elementAt(1);
  182.       this._name = s.getString();
  183.       Entity e = (Entity)ctorParams.elementAt(2);
  184.       this._metadata = new RelationViewMetaData(this, e);
  185.       Vector cols = this._metadata.getColumnList();
  186.       this.initHashTableAndBinds(cols);
  187.       int colCount = this._metadata.getColumnCount();
  188.       if (colCount > 0) {
  189.          int rowsize = 0;
  190.  
  191.          for(int i = 1; i <= colCount; ++i) {
  192.             rowsize += this._metadata.getColumnDisplaySize(i) + 20;
  193.          }
  194.  
  195.          this._numRowsToRequest = 4096 / rowsize;
  196.       }
  197.  
  198.       if (this._numRowsToRequest == 0) {
  199.          this._numRowsToRequest = 1;
  200.       }
  201.  
  202.       this._rec = new Record(new NetRecord(), this._colNames, this, (RecordSet)null);
  203.    }
  204.  
  205.    private void initHashTableAndBinds(Vector cols) {
  206.       this._colNames = new Hashtable();
  207.       this._binds = new Vector();
  208.  
  209.       for(int i = 0; i < cols.size(); ++i) {
  210.          String s = (String)cols.elementAt(i);
  211.          Integer colnum = new Integer(i + 1);
  212.          this._colNames.put(s, colnum);
  213.          this._colNames.put(colnum.toString(), colnum);
  214.          this._binds.addElement(new ProjBinder(i + 1, this, this._notifyEnabled));
  215.       }
  216.  
  217.       this._recordBinds = new Vector();
  218.    }
  219.  
  220.    private void closeStream() {
  221.       if (this._rec != null) {
  222.          this._rec.closeStream();
  223.       }
  224.  
  225.    }
  226.  
  227.    int getColIndex(String colName) throws SQLException {
  228.       Integer i = (Integer)this._colNames.get(colName);
  229.       if (i != null) {
  230.          return i;
  231.       } else {
  232.          throw new SQLException("Column not found.");
  233.       }
  234.    }
  235.  
  236.    private boolean isRecValid(Record r) {
  237.       return r != null && r.getState() != 105;
  238.    }
  239.  
  240.    private boolean isRecValid(NetRecord r) {
  241.       return r != null && r.getState() != 105;
  242.    }
  243.  
  244.    private ProjBinder getBind(int id) {
  245.       return (ProjBinder)this._binds.elementAt(id - 1);
  246.    }
  247.  
  248.    private RecordLink getRecordBind(int id) {
  249.       return (RecordLink)this._recordBinds.elementAt(id);
  250.    }
  251.  
  252.    void addDetailRelView(RelationView rv) {
  253.       this._detailRVs.addElement(rv);
  254.    }
  255.  
  256.    void notifyDataChange(int projID, Record rec) {
  257.       if (rec == this._rec) {
  258.          ProjBinder d = this.getBind(projID);
  259.          d.notifyDataChange();
  260.       }
  261.  
  262.    }
  263.  
  264.    void notifyRowStateChange() throws SQLException {
  265.       if (this._notifyEnabled) {
  266.          for(int i = 0; i < this._recordBinds.size(); ++i) {
  267.             this.getRecordBind(i).notifyRecordChange(this._rec);
  268.          }
  269.       }
  270.  
  271.    }
  272.  
  273.    void notifyRowChange() throws SQLException {
  274.       if (this._notifyEnabled) {
  275.          for(int i = 0; i < this._recordBinds.size(); ++i) {
  276.             this.getRecordBind(i).notifyRecordChange(this._rec);
  277.          }
  278.       }
  279.  
  280.       for(int i = 1; i <= this._binds.size(); ++i) {
  281.          this.getBind(i).notifyDataChange();
  282.       }
  283.  
  284.    }
  285.  
  286.    boolean notifySetData() throws SQLException {
  287.       if (this.isRecValid(this._rec)) {
  288.          for(int i = 1; i <= this._binds.size(); ++i) {
  289.             ProjBinder d = this.getBind(i);
  290.             if (!d.notifySetData()) {
  291.                return false;
  292.             }
  293.          }
  294.  
  295.          for(int i = 0; i < this._detailRVs.size(); ++i) {
  296.             RelationView rv = (RelationView)this._detailRVs.elementAt(i);
  297.             if (!rv.notifySetData()) {
  298.                return false;
  299.             }
  300.          }
  301.       }
  302.  
  303.       return true;
  304.    }
  305.  
  306.    RecordSet getRecordSet() throws SQLException {
  307.       if (this._block != null) {
  308.          return this._block;
  309.       } else {
  310.          RelViewPos pos = new RelViewPos(this.getMultiView());
  311.          pos.addParentInfo(new RelViewInfo(this._rvID, 0, this._proxyID, this._numRowsToRequest));
  312.          return this._parRV != null ? this._parRV.getChildRecordSet(pos) : this.getMultiView().getRecordSet(pos);
  313.       }
  314.    }
  315.  
  316.    RecordSet getChildRecordSet(RelViewPos pos) throws SQLException {
  317.       if (this.getCurrentRecordState() != 103 && this.getCurrentRecordState() != 104 && this._enableDetailSQL && this._curRecNum != 0) {
  318.          pos.addParentInfo(new RelViewInfo(this._rvID, this._curRecNum, this._proxyID, this._numRowsToRequest));
  319.          return this._parRV != null ? this._parRV.getChildRecordSet(pos) : this.getMultiView().getRecordSet(pos);
  320.       } else {
  321.          return null;
  322.       }
  323.    }
  324.  
  325.    void rewindDetailRelViews() throws SQLException {
  326.       for(int i = 0; i < this._detailRVs.size(); ++i) {
  327.          RelationView rv = (RelationView)this._detailRVs.elementAt(i);
  328.          rv.rewind();
  329.       }
  330.  
  331.    }
  332.  
  333.    void resetDetailRelViews(boolean bClose) throws SQLException {
  334.       for(int i = 0; i < this._detailRVs.size(); ++i) {
  335.          RelationView rv = (RelationView)this._detailRVs.elementAt(i);
  336.          rv.resetRecordSet(bClose);
  337.       }
  338.  
  339.    }
  340.  
  341.    void resetRecordSet(boolean bClose) throws SQLException {
  342.       this.closeStream();
  343.       this._block = null;
  344.       this._curRecNum = 0;
  345.       this._rec = new Record(new NetRecord(), this._colNames, this, (RecordSet)null);
  346.       if (bClose) {
  347.          this.resetDetailRelViews(bClose);
  348.          this._messgr.disable();
  349.       } else if (this.bindsExist()) {
  350.          this.goTo(1);
  351.       } else {
  352.          this.notifyRowChange();
  353.          this.resetDetailRelViews(bClose);
  354.       }
  355.    }
  356.  
  357.    boolean bindsExist() {
  358.       for(int i = 1; i <= this._binds.size(); ++i) {
  359.          if (this.getBind(i).bindsExist()) {
  360.             return true;
  361.          }
  362.       }
  363.  
  364.       return false;
  365.    }
  366.  
  367.    public void enableDetailSQL(boolean enable) throws SQLException {
  368.       if (this._enableDetailSQL != enable) {
  369.          this._enableDetailSQL = enable;
  370.          this.resetDetailRelViews(false);
  371.       }
  372.    }
  373.  
  374.    public void enableBindingNotify(boolean enable, boolean applyToDetails) throws SQLException {
  375.       this._notifyEnabled = enable;
  376.  
  377.       for(int i = 1; i <= this._binds.size(); ++i) {
  378.          this.getBind(i).enable(enable);
  379.       }
  380.  
  381.       if (applyToDetails) {
  382.          for(int i = 0; i < this._detailRVs.size(); ++i) {
  383.             RelationView rv = (RelationView)this._detailRVs.elementAt(i);
  384.             rv.enableBindingNotify(enable, applyToDetails);
  385.          }
  386.       }
  387.  
  388.    }
  389.  
  390.    public void enableBindingNotify(boolean enable) throws SQLException {
  391.       this.enableBindingNotify(enable, true);
  392.    }
  393.  
  394.    public boolean isBindingNotifyEnabled() throws SQLException {
  395.       return this._notifyEnabled;
  396.    }
  397.  
  398.    public void bindCurrentRecord(RecordLink obj) throws SQLException {
  399.       obj.init();
  400.       if (this._notifyEnabled) {
  401.          obj.notifyRecordChange(this._rec);
  402.       }
  403.  
  404.       this._recordBinds.addElement(obj);
  405.    }
  406.  
  407.    public ListBinder bindList(ConnectionInfo conn, String sql, ListLink listObj, Vector columns) throws SQLException {
  408.       int retries = 0;
  409.  
  410.       while(true) {
  411.          String username = conn.getUser();
  412.          String password = conn.getPassword();
  413.          String db = conn.getDBString();
  414.          Vector params = new Vector();
  415.          params.addElement(new TextParam(0, db));
  416.          params.addElement(new TextParam(0, username));
  417.          params.addElement(new TextParam(0, password));
  418.          params.addElement(new TextParam(0, sql));
  419.  
  420.          try {
  421.             Vector results = this._messgr.invokeMethod(6, params);
  422.             NetData d = (NetData)results.elementAt(0);
  423.             return new ListBinder(this, d.getInt(), columns, listObj, this._session, conn);
  424.          } catch (EOFException e) {
  425.             throw new SQLException(((Throwable)e).getMessage());
  426.          } catch (SQLConnectionException e) {
  427.             ++retries;
  428.             if (!this._session.logonFailed(conn, retries)) {
  429.                throw e;
  430.             }
  431.          }
  432.       }
  433.    }
  434.  
  435.    public ListBinder bindList(ConnectionInfo conn, String sql, ListLink listObj, int[] columns) throws SQLException {
  436.       Vector ids = new Vector();
  437.  
  438.       for(int i = 0; i < columns.length; ++i) {
  439.          ids.addElement(new Integer(columns[i]));
  440.       }
  441.  
  442.       return this.bindList(conn, sql, listObj, ids);
  443.    }
  444.  
  445.    public ProjBinder bindProj(int proj, ProjLink obj) throws SQLException {
  446.       ProjBinder d = this.getBind(proj);
  447.       d.addLink(obj);
  448.       obj.init(d);
  449.       if (this.getCurrentRecordState() != 105) {
  450.          this.notifyDataChange(proj, this._rec);
  451.       } else {
  452.          this.goTo(1);
  453.       }
  454.  
  455.       return d;
  456.    }
  457.  
  458.    public void closeMultiView() throws SQLException {
  459.       this._mv.close();
  460.    }
  461.  
  462.    public void deleteRecord() throws SQLException {
  463.       this._rec.delete();
  464.    }
  465.  
  466.    public boolean doesProjExist(String name) throws SQLException {
  467.       return this._colNames.containsKey(name);
  468.    }
  469.  
  470.    public int findProjByName(String name) throws SQLException {
  471.       return this.getColIndex(name);
  472.    }
  473.  
  474.    public boolean first() throws SQLException {
  475.       return this.goTo(1);
  476.    }
  477.  
  478.    public int getCurrentRecordNumber() {
  479.       return this._curRecNum;
  480.    }
  481.  
  482.    public String getCurrentRecordNumberString() {
  483.       return String.valueOf(this._curRecNum);
  484.    }
  485.  
  486.    public byte getCurrentRecordState() {
  487.       return this._rec == null ? 105 : this._rec.getState();
  488.    }
  489.  
  490.    public boolean isCurrentRecordWritable() throws SQLException {
  491.       return this._rec.isWritable();
  492.    }
  493.  
  494.    public boolean isCurrentRecordReadable() throws SQLException {
  495.       return this._rec.isReadable();
  496.    }
  497.  
  498.    public RelationViewMetaData getMetaData() throws SQLException {
  499.       return this._metadata;
  500.    }
  501.  
  502.    public MultiView getMultiView() throws SQLException {
  503.       return this._mv;
  504.    }
  505.  
  506.    public String getName() throws SQLException {
  507.       return this._name;
  508.    }
  509.  
  510.    public boolean getNewRecord() throws SQLException {
  511.       if (!this.notifySetData()) {
  512.          return false;
  513.       } else {
  514.          this.closeStream();
  515.          RecordSet block = this.getRecordSet();
  516.          if (block == null) {
  517.             this._curRecNum = 0;
  518.             this._rec = new Record(new NetRecord(), this._colNames, this, (RecordSet)null);
  519.             this.notifyRowChange();
  520.             this.resetDetailRelViews(false);
  521.             return false;
  522.          } else {
  523.             NetRecord r = block.getNewRecord();
  524.             boolean newRecValid = this.isRecValid(r);
  525.             if (newRecValid) {
  526.                this._curRecNum = r.getRecordNum();
  527.                this._rec = new Record(r, this._colNames, this, block);
  528.                this.notifyRowChange();
  529.                this.resetDetailRelViews(false);
  530.             }
  531.  
  532.             return newRecValid;
  533.          }
  534.       }
  535.    }
  536.  
  537.    public Record getRecord() throws SQLException {
  538.       return this._rec;
  539.    }
  540.  
  541.    public void rewind() throws SQLException {
  542.       if (this.notifySetData()) {
  543.          this.closeStream();
  544.          this._block = null;
  545.          this._curRecNum = 0;
  546.          this._rec = new Record(new NetRecord(), this._colNames, this, (RecordSet)null);
  547.          this.notifyRowChange();
  548.          this.rewindDetailRelViews();
  549.       }
  550.    }
  551.  
  552.    public boolean goTo(int RecordNum) throws SQLException {
  553.       if (!this.notifySetData()) {
  554.          return false;
  555.       } else {
  556.          this.closeStream();
  557.          RecordSet block = this.getRecordSet();
  558.          if (block == null) {
  559.             this._curRecNum = 0;
  560.             this._rec = new Record(new NetRecord(), this._colNames, this, (RecordSet)null);
  561.             this.notifyRowChange();
  562.             this.resetDetailRelViews(false);
  563.             return false;
  564.          } else {
  565.             NetRecord r = block.getRecord(RecordNum);
  566.             boolean newRecValid = this.isRecValid(r);
  567.             if (newRecValid) {
  568.                this._curRecNum = RecordNum;
  569.                this._rec = new Record(r, this._colNames, this, block);
  570.                this.notifyRowChange();
  571.                this.resetDetailRelViews(false);
  572.             }
  573.  
  574.             if (!newRecValid && this._curRecNum == 0) {
  575.                this.notifyRowChange();
  576.             }
  577.  
  578.             return newRecValid;
  579.          }
  580.       }
  581.    }
  582.  
  583.    public boolean goTo(String RecordNum) throws SQLException {
  584.       Integer iNum = Integer.valueOf(RecordNum);
  585.       return this.goTo(iNum);
  586.    }
  587.  
  588.    public boolean next() throws SQLException {
  589.       return this.goTo(this._curRecNum + 1);
  590.    }
  591.  
  592.    public AutoDetail getAutoDetail(ConnectionInfo conn, String sql, Properties requestProps, Properties detailProps) throws SQLException {
  593.       AutoDetail autoDetail = new AutoDetail(this, conn);
  594.       ((Request)autoDetail).setSQL(sql);
  595.       ((Request)autoDetail).setRequestProperties(requestProps);
  596.       autoDetail.setDetailProperties(detailProps);
  597.       return autoDetail;
  598.    }
  599.  
  600.    int getAutoDetailMessgrID(ConnectionInfo conn, String sql, Properties requestProps, Properties detailProps) throws SQLException {
  601.       Vector results = this._messgr.invokeMethod(1, "RelView");
  602.       NetData d = (NetData)results.elementAt(0);
  603.  
  604.       try {
  605.          int id = d.getInt();
  606.          return id;
  607.       } catch (EOFException e) {
  608.          throw new SQLException(((Throwable)e).getMessage());
  609.       }
  610.    }
  611.  
  612.    public AutoDetail getAutoDetail() throws SQLException {
  613.       return this.getAutoDetail("");
  614.    }
  615.  
  616.    int getAutoDetailMessgrID() throws SQLException {
  617.       return this.getAutoDetailMessgrID("");
  618.    }
  619.  
  620.    public AutoDetail getAutoDetail(String sql) throws SQLException {
  621.       return this.getAutoDetail(this._conn, sql, new Properties(), new Properties());
  622.    }
  623.  
  624.    int getAutoDetailMessgrID(String sql) throws SQLException {
  625.       return this.getAutoDetailMessgrID(this._conn, sql, new Properties(), new Properties());
  626.    }
  627.  
  628.    public boolean prev() throws SQLException {
  629.       return this._curRecNum == 0 ? false : this.goTo(this._curRecNum - 1);
  630.    }
  631.  
  632.    public void saveMultiView() throws SQLException {
  633.       this._mv.save();
  634.    }
  635.  
  636.    public void restartMultiView() throws SQLException {
  637.       this._mv.restart();
  638.    }
  639.  
  640.    public void setName(String newName) throws SQLException {
  641.       this._messgr.invokeMethod(3, newName);
  642.       this._name = newName;
  643.    }
  644.  
  645.    public void unBindObj(Object obj) throws SQLException {
  646.       for(int i = 1; i <= this._binds.size(); ++i) {
  647.          this.getBind(i).removeLink(obj);
  648.       }
  649.  
  650.    }
  651.  
  652.    public void unBindProj(int proj) throws SQLException {
  653.       this.getBind(proj).removeAllLinks();
  654.    }
  655.  
  656.    public void undoRecord() throws SQLException {
  657.       this._rec.undo();
  658.       this.notifyRowChange();
  659.    }
  660.  
  661.    public boolean isNull(int proj) throws SQLException {
  662.       return this._rec.isNull(proj);
  663.    }
  664.  
  665.    public String getString(int proj) throws SQLException {
  666.       return this._rec.getString(proj);
  667.    }
  668.  
  669.    public boolean getBoolean(int proj) throws SQLException {
  670.       return this._rec.getBoolean(proj);
  671.    }
  672.  
  673.    public byte getByte(int proj) throws SQLException {
  674.       return this._rec.getByte(proj);
  675.    }
  676.  
  677.    public short getShort(int proj) throws SQLException {
  678.       return this._rec.getShort(proj);
  679.    }
  680.  
  681.    public int getInt(int proj) throws SQLException {
  682.       return this._rec.getInt(proj);
  683.    }
  684.  
  685.    public long getLong(int proj) throws SQLException {
  686.       return this._rec.getLong(proj);
  687.    }
  688.  
  689.    public float getFloat(int proj) throws SQLException {
  690.       return this._rec.getFloat(proj);
  691.    }
  692.  
  693.    public double getDouble(int proj) throws SQLException {
  694.       return this._rec.getDouble(proj);
  695.    }
  696.  
  697.    public Bignum getBignum(int proj, int scale) throws SQLException {
  698.       return this._rec.getBignum(proj, scale);
  699.    }
  700.  
  701.    public byte[] getBytes(int proj) throws SQLException {
  702.       return this._rec.getBytes(proj);
  703.    }
  704.  
  705.    public Date getDate(int proj) throws SQLException {
  706.       return this._rec.getDate(proj);
  707.    }
  708.  
  709.    public Time getTime(int proj) throws SQLException {
  710.       return this._rec.getTime(proj);
  711.    }
  712.  
  713.    public Timestamp getTimestamp(int proj) throws SQLException {
  714.       return this._rec.getTimestamp(proj);
  715.    }
  716.  
  717.    public InputStream getAsciiStream(int proj) throws SQLException {
  718.       return this._rec.getAsciiStream(proj);
  719.    }
  720.  
  721.    public InputStream getUnicodeStream(int proj) throws SQLException {
  722.       return this._rec.getUnicodeStream(proj);
  723.    }
  724.  
  725.    public InputStream getBinaryStream(int proj) throws SQLException {
  726.       return this._rec.getBinaryStream(proj);
  727.    }
  728.  
  729.    public String getStringValue(int proj, int scale) throws SQLException, IOException {
  730.       return this._rec.getStringValue(proj, scale);
  731.    }
  732.  
  733.    public String getStringValue(int proj, int scale, boolean processBinaryData) throws SQLException, IOException {
  734.       return this._rec.getStringValue(proj, scale);
  735.    }
  736.  
  737.    public String getStringValue(int proj) throws SQLException, IOException {
  738.       return this._rec.getStringValue(proj);
  739.    }
  740.  
  741.    public String getStringValue(int proj, boolean processBinaryData) throws SQLException, IOException {
  742.       return this._rec.getStringValue(proj, processBinaryData);
  743.    }
  744.  
  745.    public String getStringValue(int proj, String columnTypeName, int scale) throws SQLException, IOException {
  746.       return this._rec.getStringValue(proj, columnTypeName, scale);
  747.    }
  748.  
  749.    public String getStringValue(int proj, String columnTypeName, int scale, boolean processBinaryData) throws SQLException, IOException {
  750.       return this._rec.getStringValue(proj, columnTypeName, scale, processBinaryData);
  751.    }
  752.  
  753.    public String getStringValue(int proj, int columnType, int scale) throws SQLException, IOException {
  754.       return this._rec.getStringValue(proj, columnType, scale);
  755.    }
  756.  
  757.    public String getStringValue(int proj, int columnType, int scale, boolean processBinaryData) throws SQLException, IOException {
  758.       return this._rec.getStringValue(proj, columnType, scale, processBinaryData);
  759.    }
  760.  
  761.    public boolean isNull(String projName) throws SQLException {
  762.       return this._rec.isNull(projName);
  763.    }
  764.  
  765.    public String getString(String projName) throws SQLException {
  766.       return this._rec.getString(projName);
  767.    }
  768.  
  769.    public boolean getBoolean(String projName) throws SQLException {
  770.       return this._rec.getBoolean(projName);
  771.    }
  772.  
  773.    public byte getByte(String projName) throws SQLException {
  774.       return this._rec.getByte(projName);
  775.    }
  776.  
  777.    public short getShort(String projName) throws SQLException {
  778.       return this._rec.getShort(projName);
  779.    }
  780.  
  781.    public int getInt(String projName) throws SQLException {
  782.       return this._rec.getInt(projName);
  783.    }
  784.  
  785.    public long getLong(String projName) throws SQLException {
  786.       return this._rec.getLong(projName);
  787.    }
  788.  
  789.    public float getFloat(String projName) throws SQLException {
  790.       return this._rec.getFloat(projName);
  791.    }
  792.  
  793.    public double getDouble(String projName) throws SQLException {
  794.       return this._rec.getDouble(projName);
  795.    }
  796.  
  797.    public Bignum getBignum(String projName, int scale) throws SQLException {
  798.       return this._rec.getBignum(projName, scale);
  799.    }
  800.  
  801.    public byte[] getBytes(String projName) throws SQLException {
  802.       return this._rec.getBytes(projName);
  803.    }
  804.  
  805.    public Date getDate(String projName) throws SQLException {
  806.       return this._rec.getDate(projName);
  807.    }
  808.  
  809.    public Time getTime(String projName) throws SQLException {
  810.       return this._rec.getTime(projName);
  811.    }
  812.  
  813.    public Timestamp getTimestamp(String projName) throws SQLException {
  814.       return this._rec.getTimestamp(projName);
  815.    }
  816.  
  817.    public InputStream getAsciiStream(String projName) throws SQLException {
  818.       return this._rec.getAsciiStream(projName);
  819.    }
  820.  
  821.    public InputStream getUnicodeStream(String projName) throws SQLException {
  822.       return this._rec.getUnicodeStream(projName);
  823.    }
  824.  
  825.    public InputStream getBinaryStream(String projName) throws SQLException {
  826.       return this._rec.getBinaryStream(projName);
  827.    }
  828.  
  829.    public String getStringValue(String projName, int scale) throws SQLException, IOException {
  830.       return this._rec.getStringValue(projName, scale);
  831.    }
  832.  
  833.    public String getStringValue(String projName, int scale, boolean processBinaryData) throws SQLException, IOException {
  834.       return this._rec.getStringValue(projName, scale, processBinaryData);
  835.    }
  836.  
  837.    public String getStringValue(String projName) throws SQLException, IOException {
  838.       return this._rec.getStringValue(projName);
  839.    }
  840.  
  841.    public String getStringValue(String projName, boolean processBinaryData) throws SQLException, IOException {
  842.       return this._rec.getStringValue(projName, processBinaryData);
  843.    }
  844.  
  845.    public String getStringValue(String projName, String columnTypeName, int scale) throws SQLException, IOException {
  846.       return this._rec.getStringValue(projName, columnTypeName, scale);
  847.    }
  848.  
  849.    public String getStringValue(String projName, String columnTypeName, int scale, boolean processBinaryData) throws SQLException, IOException {
  850.       return this._rec.getStringValue(projName, columnTypeName, scale, processBinaryData);
  851.    }
  852.  
  853.    public String getStringValue(String projName, int columnType, int scale) throws SQLException, IOException {
  854.       return this._rec.getStringValue(projName, columnType, scale);
  855.    }
  856.  
  857.    public String getStringValue(String projName, int columnType, int scale, boolean processBinaryData) throws SQLException, IOException {
  858.       return this._rec.getStringValue(projName, columnType, scale, processBinaryData);
  859.    }
  860.  
  861.    public void setNull(int proj, int sqlType) throws SQLException {
  862.       this._rec.setNull(proj, sqlType);
  863.    }
  864.  
  865.    public void setBoolean(int proj, boolean x) throws SQLException {
  866.       this._rec.setBoolean(proj, x);
  867.    }
  868.  
  869.    public void setByte(int proj, byte x) throws SQLException {
  870.       this._rec.setByte(proj, x);
  871.    }
  872.  
  873.    public void setShort(int proj, short x) throws SQLException {
  874.       this._rec.setShort(proj, x);
  875.    }
  876.  
  877.    public void setInt(int proj, int x) throws SQLException {
  878.       this._rec.setInt(proj, x);
  879.    }
  880.  
  881.    public void setLong(int proj, long x) throws SQLException {
  882.       this._rec.setLong(proj, x);
  883.    }
  884.  
  885.    public void setFloat(int proj, float x) throws SQLException {
  886.       this._rec.setFloat(proj, x);
  887.    }
  888.  
  889.    public void setDouble(int proj, double x) throws SQLException {
  890.       this._rec.setDouble(proj, x);
  891.    }
  892.  
  893.    public void setBignum(int proj, Bignum x) throws SQLException {
  894.       this._rec.setBignum(proj, x);
  895.    }
  896.  
  897.    public void setString(int proj, String x) throws SQLException {
  898.       this._rec.setString(proj, x);
  899.    }
  900.  
  901.    public void setBytes(int proj, byte[] x) throws SQLException {
  902.       this._rec.setBytes(proj, x);
  903.    }
  904.  
  905.    public void setDate(int proj, Date x) throws SQLException {
  906.       this._rec.setDate(proj, x);
  907.    }
  908.  
  909.    public void setTime(int proj, Time x) throws SQLException {
  910.       this._rec.setTime(proj, x);
  911.    }
  912.  
  913.    public void setTimestamp(int proj, Timestamp x) throws SQLException {
  914.       this._rec.setTimestamp(proj, x);
  915.    }
  916.  
  917.    public void setAsciiStream(int proj, InputStream x, int length) throws SQLException {
  918.       this._rec.setAsciiStream(proj, x, length);
  919.    }
  920.  
  921.    public void setUnicodeStream(int proj, InputStream x, int length) throws SQLException {
  922.       this._rec.setUnicodeStream(proj, x, length);
  923.    }
  924.  
  925.    public void setBinaryStream(int proj, InputStream x, int length) throws SQLException {
  926.       this._rec.setBinaryStream(proj, x, length);
  927.    }
  928.  
  929.    public void setValueFromString(int proj, String data, int scale, int treatBlankAsNull) throws SQLException, IOException {
  930.       this._rec.setValueFromString(proj, data, scale, treatBlankAsNull);
  931.    }
  932.  
  933.    public void setValueFromString(int proj, String data) throws SQLException, IOException {
  934.       this._rec.setValueFromString(proj, data);
  935.    }
  936.  
  937.    public void setValueFromString(int proj, String data, int treatBlankAsNull) throws SQLException, IOException {
  938.       this._rec.setValueFromString(proj, data, treatBlankAsNull);
  939.    }
  940.  
  941.    public void setValueFromString(int proj, String data, String columnTypeName, int scale) throws SQLException, IOException {
  942.       this._rec.setValueFromString(proj, data, columnTypeName, scale);
  943.    }
  944.  
  945.    public void setValueFromString(int proj, String data, String columnTypeName, int scale, int treatBlankAsNull) throws SQLException, IOException {
  946.       this._rec.setValueFromString(proj, data, columnTypeName, scale, treatBlankAsNull);
  947.    }
  948.  
  949.    public void setValueFromString(int proj, String data, int columnType, int scale, int treatBlankAsNull) throws SQLException, IOException {
  950.       this._rec.setValueFromString(proj, data, columnType, scale, treatBlankAsNull);
  951.    }
  952.  
  953.    public void setNull(String projName, int sqlType) throws SQLException {
  954.       this._rec.setNull(projName, sqlType);
  955.    }
  956.  
  957.    public void setBoolean(String projName, boolean x) throws SQLException {
  958.       this._rec.setBoolean(projName, x);
  959.    }
  960.  
  961.    public void setByte(String projName, byte x) throws SQLException {
  962.       this._rec.setByte(projName, x);
  963.    }
  964.  
  965.    public void setShort(String projName, short x) throws SQLException {
  966.       this._rec.setShort(projName, x);
  967.    }
  968.  
  969.    public void setInt(String projName, int x) throws SQLException {
  970.       this._rec.setInt(projName, x);
  971.    }
  972.  
  973.    public void setLong(String projName, long x) throws SQLException {
  974.       this._rec.setLong(projName, x);
  975.    }
  976.  
  977.    public void setFloat(String projName, float x) throws SQLException {
  978.       this._rec.setFloat(projName, x);
  979.    }
  980.  
  981.    public void setDouble(String projName, double x) throws SQLException {
  982.       this._rec.setDouble(projName, x);
  983.    }
  984.  
  985.    public void setBignum(String projName, Bignum x) throws SQLException {
  986.       this._rec.setBignum(projName, x);
  987.    }
  988.  
  989.    public void setString(String projName, String x) throws SQLException {
  990.       this._rec.setString(projName, x);
  991.    }
  992.  
  993.    public void setBytes(String projName, byte[] x) throws SQLException {
  994.       this._rec.setBytes(projName, x);
  995.    }
  996.  
  997.    public void setDate(String projName, Date x) throws SQLException {
  998.       this._rec.setDate(projName, x);
  999.    }
  1000.  
  1001.    public void setTime(String projName, Time x) throws SQLException {
  1002.       this._rec.setTime(projName, x);
  1003.    }
  1004.  
  1005.    public void setTimestamp(String projName, Timestamp x) throws SQLException {
  1006.       this._rec.setTimestamp(projName, x);
  1007.    }
  1008.  
  1009.    public void setAsciiStream(String projName, InputStream x, int length) throws SQLException {
  1010.       this._rec.setAsciiStream(projName, x, length);
  1011.    }
  1012.  
  1013.    public void setUnicodeStream(String projName, InputStream x, int length) throws SQLException {
  1014.       this._rec.setUnicodeStream(projName, x, length);
  1015.    }
  1016.  
  1017.    public void setBinaryStream(String projName, InputStream x, int length) throws SQLException {
  1018.       this._rec.setBinaryStream(projName, x, length);
  1019.    }
  1020.  
  1021.    public void setValueFromString(String projName, String data, int scale, int treatBlankAsNull) throws SQLException, IOException {
  1022.       this._rec.setValueFromString(projName, data, scale, treatBlankAsNull);
  1023.    }
  1024.  
  1025.    public void setValueFromString(String projName, String data) throws SQLException, IOException {
  1026.       this._rec.setValueFromString(projName, data);
  1027.    }
  1028.  
  1029.    public void setValueFromString(String projName, String data, int treatBlankAsNull) throws SQLException, IOException {
  1030.       this._rec.setValueFromString(projName, data, treatBlankAsNull);
  1031.    }
  1032.  
  1033.    public void setValueFromString(String projName, String data, String columnTypeName, int scale) throws SQLException, IOException {
  1034.       this._rec.setValueFromString(projName, data, columnTypeName, scale);
  1035.    }
  1036.  
  1037.    public void setValueFromString(String projName, String data, String columnTypeName, int scale, int treatBlankAsNull) throws SQLException, IOException {
  1038.       this._rec.setValueFromString(projName, data, columnTypeName, scale, treatBlankAsNull);
  1039.    }
  1040.  
  1041.    public void setValueFromString(String projName, String data, int columnType, int scale, int treatBlankAsNull) throws SQLException, IOException {
  1042.       this._rec.setValueFromString(projName, data, columnType, scale, treatBlankAsNull);
  1043.    }
  1044.  
  1045.    public static String asciiStreamtoString(InputStream is) throws IOException {
  1046.       String s;
  1047.       int i;
  1048.       for(s = ""; (i = is.read()) != -1; s = s + (char)i) {
  1049.       }
  1050.  
  1051.       return s;
  1052.    }
  1053.  
  1054.    public static String binaryArraytoString(byte[] b) throws IOException {
  1055.       String s = "";
  1056.       int count = Math.min(b.length, 255);
  1057.  
  1058.       for(int i = 0; i < count; ++i) {
  1059.          if (b[i] == 0) {
  1060.             s = s + "/0";
  1061.          } else {
  1062.             s = s + b[i];
  1063.          }
  1064.       }
  1065.  
  1066.       return s;
  1067.    }
  1068.  
  1069.    public static String binaryStreamtoString(InputStream is, int length) throws IOException {
  1070.       String s = "";
  1071.  
  1072.       int i;
  1073.       for(int count = length; (i = is.read()) != -1 && count-- > 0; s = s + "/" + i) {
  1074.       }
  1075.  
  1076.       return s;
  1077.    }
  1078.  
  1079.    public static int sqlTypeConvert(String typename) {
  1080.       if (typename.equals("Char")) {
  1081.          return 1;
  1082.       } else if (typename.equals("VarChar")) {
  1083.          return 12;
  1084.       } else if (typename.equals("LongVarChar")) {
  1085.          return -1;
  1086.       } else if (typename.equals("Bit")) {
  1087.          return -7;
  1088.       } else if (typename.equals("TinyInt")) {
  1089.          return -6;
  1090.       } else if (typename.equals("SmallInt")) {
  1091.          return 5;
  1092.       } else if (typename.equals("Integer")) {
  1093.          return 4;
  1094.       } else if (typename.equals("BigInt")) {
  1095.          return -5;
  1096.       } else if (typename.equals("Float")) {
  1097.          return 6;
  1098.       } else if (typename.equals("Real")) {
  1099.          return 7;
  1100.       } else if (typename.equals("Double")) {
  1101.          return 8;
  1102.       } else if (typename.equals("Numeric")) {
  1103.          return 2;
  1104.       } else if (typename.equals("Decimal")) {
  1105.          return 3;
  1106.       } else if (typename.equals("Date")) {
  1107.          return 91;
  1108.       } else if (typename.equals("Time")) {
  1109.          return 92;
  1110.       } else if (typename.equals("Timestamp")) {
  1111.          return 93;
  1112.       } else if (typename.equals("Binary")) {
  1113.          return -2;
  1114.       } else if (typename.equals("VarBinary")) {
  1115.          return -3;
  1116.       } else if (typename.equals("LongVarBinary")) {
  1117.          return -4;
  1118.       } else if (typename.equals("Other")) {
  1119.          return 1111;
  1120.       } else {
  1121.          return typename.equals("Null") ? 0 : 1111;
  1122.       }
  1123.    }
  1124.  
  1125.    public static String sqlTypeConvert(int typeid) {
  1126.       if (typeid == 1) {
  1127.          return "Char";
  1128.       } else if (typeid == 12) {
  1129.          return "VarChar";
  1130.       } else if (typeid == -1) {
  1131.          return "LongVarChar";
  1132.       } else if (typeid == -7) {
  1133.          return "Bit";
  1134.       } else if (typeid == -6) {
  1135.          return "TinyInt";
  1136.       } else if (typeid == 5) {
  1137.          return "SmallInt";
  1138.       } else if (typeid == 4) {
  1139.          return "Integer";
  1140.       } else if (typeid == -5) {
  1141.          return "BigInt";
  1142.       } else if (typeid == 6) {
  1143.          return "Float";
  1144.       } else if (typeid == 7) {
  1145.          return "Real";
  1146.       } else if (typeid == 8) {
  1147.          return "Double";
  1148.       } else if (typeid == 2) {
  1149.          return "Numeric";
  1150.       } else if (typeid == 3) {
  1151.          return "Decimal";
  1152.       } else if (typeid == 91) {
  1153.          return "Date";
  1154.       } else if (typeid == 92) {
  1155.          return "Time";
  1156.       } else if (typeid == 93) {
  1157.          return "Timestamp";
  1158.       } else if (typeid == -2) {
  1159.          return "Binary";
  1160.       } else if (typeid == -3) {
  1161.          return "VarBinary";
  1162.       } else if (typeid == -4) {
  1163.          return "LongVarBinary";
  1164.       } else if (typeid == 1111) {
  1165.          return "Other";
  1166.       } else {
  1167.          return typeid == 0 ? "Null" : "Other";
  1168.       }
  1169.    }
  1170.  
  1171.    public static String processEmptyStringData(String data, RelationView rv, int proj, int columnType, int treatBlankAsNull) throws SQLException {
  1172.       if (treatBlankAsNull == 0) {
  1173.          if (rv.isNull(proj) || columnType != 1 && columnType != 12 && columnType != -1) {
  1174.             data = null;
  1175.          } else {
  1176.             data = "";
  1177.          }
  1178.       } else if (treatBlankAsNull != 1 && columnType != -2 && columnType != -3 && columnType != -4 && columnType != 1111) {
  1179.          if (treatBlankAsNull == 2) {
  1180.             switch (columnType) {
  1181.                case -7:
  1182.                case -6:
  1183.                case -5:
  1184.                case 2:
  1185.                case 3:
  1186.                case 4:
  1187.                case 5:
  1188.                case 6:
  1189.                case 7:
  1190.                case 8:
  1191.                   data = "0";
  1192.                   break;
  1193.                case -1:
  1194.                case 1:
  1195.                case 12:
  1196.                   data = "";
  1197.                   break;
  1198.                case 91:
  1199.                   data = "1970-01-01";
  1200.                   break;
  1201.                case 92:
  1202.                   data = "12:00:00";
  1203.                   break;
  1204.                case 93:
  1205.                   data = "1970-01-01 12:00:00.0";
  1206.             }
  1207.          }
  1208.       } else {
  1209.          data = null;
  1210.       }
  1211.  
  1212.       return data;
  1213.    }
  1214.  
  1215.    public RelationView getParentRelationView() {
  1216.       return this._parRV;
  1217.    }
  1218. }
  1219.